home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / common / accountbase.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  4KB  |  93 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import cPickle
  5. from util.observe import Observable
  6. from common import HashedAccount
  7. from common.actions import ActionMeta
  8. from common import profile
  9. from util import dictdiff
  10.  
  11. class AccountBase(Observable, HashedAccount):
  12.     max_error_tolerance = 3
  13.     __metaclass__ = ActionMeta
  14.     _ids = []
  15.     
  16.     def next_id(cls):
  17.         i = len(cls._ids) - 1
  18.         for i, j in enumerate(sorted(cls._ids)):
  19.             if i != j:
  20.                 break
  21.                 continue
  22.         else:
  23.             i += 1
  24.         cls._ids.insert(i, i)
  25.         return i
  26.  
  27.     next_id = classmethod(next_id)
  28.     
  29.     def __init__(self, name, password, **options):
  30.         Observable.__init__(self)
  31.         self.name = name
  32.         self.password = password
  33.         self.id = None if 'id' in options else self.next_id()
  34.         self.error_count = 0
  35.  
  36.     
  37.     def popupids(self):
  38.         return set((self,))
  39.  
  40.     popupids = property(popupids)
  41.     
  42.     def username(self):
  43.         return self.name
  44.  
  45.     username = property(username)
  46.     
  47.     def protocol_class(self):
  48.         proto_init = proto_init
  49.         import common.protocolmeta
  50.         return proto_init(self.protocol)
  51.  
  52.     
  53.     def _repr(self):
  54.         return '<%s %s (%s) %s, %r>' % (self.__class__.__name__, self.name, getattr(self, 'protocol', None), getattr(self, 'state', None), getattr(self, 'offline_reason', None))
  55.  
  56.     _repr = staticmethod(_repr)
  57.     
  58.     def __repr__(self):
  59.         return self._repr(self)
  60.  
  61.     
  62.     def default(self, key):
  63.         return self.protocol_info()['defaults'][key]
  64.  
  65.     
  66.     def get_options(self):
  67.         opts = self._get_options()
  68.         d = self.protocol_info()['defaults']
  69.         return dictdiff(d, opts)
  70.  
  71.     
  72.     def _decryptedpw(self):
  73.         return profile.plain_pw(self.password)
  74.  
  75.  
  76.  
  77. class FromNetMixin(object):
  78.     
  79.     def __init__(self, *a, **k):
  80.         pass
  81.  
  82.     
  83.     def from_net(cls, info, **extra):
  84.         proto_init = proto_init
  85.         import common.protocolmeta
  86.         Class = proto_init(info.protocol)
  87.         cls._ids.insert(info.id, info.id)
  88.         extra.update(**cPickle.loads(info.data))
  89.         return Class(name = info.username, password = info.password, id = info.id, **extra)
  90.  
  91.     from_net = classmethod(from_net)
  92.  
  93.